/*!
 * \file frlist_empty.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frlist.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __my_list_node_free(Frlist_node *node)
{
    if(node && node->data)
        frfree(node->data);

    return;
}

static void __case1(void)
{
    int i_ret = 0;

    Frlist_header *list = NULL;

    i_ret = frlist_empty(list);

    CU_ASSERT_EQUAL(i_ret,FR_YES);
    return;
}

static void __case2(void)
{
    int i_ret = 0;

    Frlist_header *list = NULL;

    list = frlist_create();
    i_ret = frlist_empty(list);

    CU_ASSERT_EQUAL(i_ret,FR_YES);

    frfree(list);
    return;
}
static void __case3(void)
{
    int i_ret = 0;
    Frlist_header *list;
    Frlist_node *list_node;
    char *p_data = NULL;

    list = frlist_create();

    p_data = (char *)frmalloc(5);
    snprintf(p_data,5,"%s","test");

    list_node = frlist_node_create(p_data);
    frlist_add_tail(list,list_node);

    i_ret = frlist_empty(list);

    CU_ASSERT_EQUAL(i_ret,FR_NO);

    frlist_destroy(list,__my_list_node_free);
    return;

}


int add_suite_frlist_empty(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frlist frlist_empty()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);
    CU_add_test(pSuite, "case3", __case3);

    return FR_SUCC;
}
